// pages/page1/pagewzsj/wzsj.js
var app = getApp()
Page({
	data: {
		hidden:true,
		curNav:10,
		curIndex:0,
		getProdCatlg:'',
		cartTotal:'',
		BizCatlg:'软件&信息',
		BizCatlgId:'10',
		subCatlg:'',
		subCatlgId:''	
	},
	loadingChange () {
		setTimeout(() => {
			this.setData({
				hidden:true
			})
		},2000)
	},
	selectNav (event) {
		let id = event.target.dataset.id,
			name = event.target.dataset.name,
			index = parseInt(event.target.dataset.index);
			self = this;	
		this.setData({
			curNav:id,
			curIndex:index,
			BizCatlg:name,
			subCatlgId:'',
			subCatlg:'',
			cartTotal:name
		})
	},
	selectD (e) {
		var subCatlg= e.currentTarget.dataset.name,
			subCatlgId = e.currentTarget.dataset.dish;
		this.setData({
			subCatlgId:subCatlgId,
			subCatlg:subCatlg,
			cartTotal:subCatlg
		})	
	},	
	//选择产品
	selectDish (e) {
		var that = this;	
		if(that.data.cartTotal==''){
			app.showModal({
            content: '请至少选择一种行业！'
          });
		  return false;
		}
		var change_ca={
			BizCatlg:that.data.BizCatlg,
			BizCatlgId:that.data.BizCatlgId,
			subCatlg:that.data.subCatlg,
			subCatlgId:that.data.subCatlgId,
		}
		var returnpage = this.data.returnpage;
		if(returnpage=='page10000'){
			wx.setStorage({
				key: 'prodcatlg',
				data: change_ca
			})
			app.globalData.page10000_inital = true;
			wx.switchTab({
				url: '../page10000/page10000',
				success: function(res){
				// success
				}
			})
		}else if(returnpage=='addproduct'){
			var getProdCatlg = this.data.getProdCatlg;
	    	var curIndex = this.data.curIndex;
			app.globalData.change_ca = change_ca;
			wx.navigateBack({
			  delta: 1, // 回退前 delta(默认为1) 页面
			  success: function(res){
				// success
			  },			 
			})
		}else if(returnpage=='addcompany'){
			var getProdCatlg = this.data.getProdCatlg;
	    	var curIndex = this.data.curIndex;			
			app.globalData.change_com = change_ca;
			wx.navigateBack({
			  delta: 1, // 回退前 delta(默认为1) 页面
			  success: function(res){
				// success
			  },			 
			})
		}
	},
	 select(dishId) {
		let dishes = this.data.dishesList;
		for (let dish of dishes){
			dish.forEach((item) => {
				if(item.id == dishId){
					item.status = !item.status || false
				}
			})
		}
		
		this.setData({
			dishesList:this.data.dishesList
		})
	},
	onLoad (e) {
		this.setData({
			returnpage:e.returnpage
		})
		//this.loadingChange();
		this.requestList();
	},
	requestList:function(){
		var that = this;
		var value = wx.getStorageSync('getProdCatlg');
		if(value){
			that.setData({
			   getProdCatlg:value
			})  
			return false ;		
		}
		var param = app.globalData.session_key;
	    var getProdCatlg ={
			token :param.myXcxSessionId,
			source:'1', 
			}
		app.sendRequest({
		url:'/prod/getProdCatlg',
		data:getProdCatlg,
		method:'POST',
		header:{
			'content-type':'application/json'
			},
		success: function(res){
			var data = res.data;  
			that.setData({
			   getProdCatlg:data
			})  
			wx.setStorage({
				key: 'getProdCatlg',
				data: data
			})  
		}
		});	
	}
})